<template>
  <div class="success-container">
    <!-- 头部标题 -->
    <div class="header">
      <span class="header-title">支付结果</span>
    </div>

    <!-- 支付成功内容 -->
    <div class="success-content">
      <!-- 成功图标 -->
      <div class="success-icon">
        ✅
      </div>

      <!-- 成功提示文字 -->
      <h2 class="success-title">支付成功</h2>
      <p class="success-subtitle">您的订单已支付成功，感谢您的购买</p>

      <!-- 订单信息 -->
      <div class="order-info">
        <div class="info-item">
          <span class="info-label">订单编号：</span>
          <span class="info-value">{{ orderId || 'QD' + Date.now().toString().slice(-8) }}</span>
        </div>
        <div class="info-item">
          <span class="info-label">支付金额：</span>
          <span class="info-value amount">¥{{ paymentAmount }}</span>
        </div>
        <div class="info-item">
          <span class="info-label">支付时间：</span>
          <span class="info-value">{{ currentTime }}</span>
        </div>
        <div class="info-item" v-if="companyName">
          <span class="info-label">查询企业：</span>
          <span class="info-value">{{ companyName }}</span>
        </div>
      </div>

      <!-- 服务提示 -->
      <div class="service-tips">
        <p>📝 您可以在订单中心查看详细订单信息</p>
        <p>📊 查询结果将在24小时内完成</p>
      </div>
    </div>

    <!-- 底部按钮 -->
    <div class="bottom-buttons">
      <!-- <button class="button primary-button" @click="gotoOrderList">
        查看订单
      </button> -->
      <button class="button secondary-button" @click="gotoHome">
        返回首页
      </button>
    </div>
  </div>
</template>

<script setup>
import { ref, onMounted } from 'vue'
import { useRouter } from 'vue-router'

const router = useRouter()

// 响应式数据
const orderId = ref('')
const paymentAmount = ref('359.00')
const companyName = ref('')
const currentTime = ref('')

// 生命周期钩子
onMounted(() => {
  // 获取URL参数
  const urlParams = new URLSearchParams(window.location.search)
  orderId.value = urlParams.get('orderId') || ''
  paymentAmount.value = urlParams.get('amount') || '359.00'
  companyName.value = urlParams.get('companyName') || ''
  
  // 设置当前时间
  updateCurrentTime()
})

// 更新当前时间
const updateCurrentTime = () => {
  const now = new Date()
  const year = now.getFullYear()
  const month = String(now.getMonth() + 1).padStart(2, '0')
  const day = String(now.getDate()).padStart(2, '0')
  const hours = String(now.getHours()).padStart(2, '0')
  const minutes = String(now.getMinutes()).padStart(2, '0')
  const seconds = String(now.getSeconds()).padStart(2, '0')
  
  currentTime.value = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`
}

// // 跳转到订单列表
// const gotoOrderList = () => {
//   router.push('/pages/order/index')
// }

// 返回首页
const gotoHome = () => {
  router.push('/')
}
</script>

<style scoped>
.success-container {
  background-color: #f5f5f5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* 头部样式 */
.header {
  background-color: #1890ff;
  color: white;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: sticky;
  top: 0;
  z-index: 1000;
}

.header-title {
  font-size: 18px;
  font-weight: bold;
  color: white;
}

/* 支付成功内容 */
.success-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 20px;
  text-align: center;
}

/* 成功图标 */
.success-icon {
  font-size: 80px;
  margin-bottom: 20px;
  animation: successBounce 1s ease-in-out;
}

@keyframes successBounce {
  0% { transform: scale(0.5); opacity: 0; }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); opacity: 1; }
}

/* 成功提示文字 */
.success-title {
  font-size: 24px;
  font-weight: bold;
  color: #333;
  margin-bottom: 10px;
}

.success-subtitle {
  font-size: 16px;
  color: #666;
  margin-bottom: 30px;
}

/* 订单信息 */
.order-info {
  background-color: white;
  width: 100%;
  max-width: 400px;
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 30px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.info-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid #f0f0f0;
}

.info-item:last-child {
  border-bottom: none;
}

.info-label {
  font-size: 14px;
  color: #666;
}

.info-value {
  font-size: 14px;
  color: #333;
  text-align: right;
}

.info-value.amount {
  font-size: 20px;
  font-weight: bold;
  color: #1890ff;
}

/* 服务提示 */
.service-tips {
  background-color: #e6f7ff;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 40px;
  text-align: left;
  width: 100%;
  max-width: 400px;
}

.service-tips p {
  font-size: 14px;
  color: #333;
  margin: 6px 0;
}

/* 底部按钮 */
.bottom-buttons {
  padding: 20px;
  background-color: white;
  border-top: 1px solid #f0f0f0;
}

.button {
  width: 100%;
  height: 48px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  border: none;
  margin-bottom: 12px;
  transition: all 0.3s ease;
}

.primary-button {
  background-color: #1890ff;
  color: white;
}

.primary-button:hover {
  background-color: #40a9ff;
}

.secondary-button {
  background-color: white;
  color: #1890ff;
  border: 1px solid #d9d9d9;
}

.secondary-button:hover {
  color: #40a9ff;
  border-color: #40a9ff;
}
</style>